var displayedCatMenu = false;
var isClickedCatMenu = false;


/*
 * when click a place, fire events : click directive element(button), and finally click html
 */
function clickElements(){
    var currClickedTag = $(this).get(0).tagName;
    var idTag = $(this).attr('id');
    if(idTag=="nav_category"){
        isClickedCatMenu = true;
    }
    if(currClickedTag == 'HTML'){
        if(isClickedCatMenu){
            if(!displayedCatMenu){
                $("#categorybook").css("display","block");
                displayedCatMenu =true;
            }
            else{
                $("#categorybook").css("display","none");
                displayedCatMenu =false;
                isClickedCatMenu = false;
            }
        }
        else{
            $("#categorybook").css("display","none");
            displayedCatMenu =false;
        }
    }
}
$(document).ready(function(){
    $('*').click(clickElements);
});